<?php
$ch=curl_init();
$url="http://zhibohenan.com/index.php/Home/Type/index/typeid/1.html";
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

$data=curl_exec($ch);
$res='#<div id="article_161634" class="chanlDiv">.*<p class="titleP">.*<span>.*<a title=".*" href=".*">(.*)</a>.*</span>.*</p>.*<img width="150" height="100" src="(.*)">.*<div class="chanDay">.*<span>(.*)</span>.*</div>.*</div>#isU';

preg_match_all($res,$data,$rud);
$g_name=$rud[1];
$g_desc=$rud[2];
$g_autho=$rud[3];


$sql="insert into games(`g_name`,`g_desc`,`g_autho`) VALUES";
foreach($g_name as $k=>$v)
{
    $sql.="('$g_name[$k]','$g_desc[$k]','$g_autho[$k]'),";
}
$sql=substr($sql,0,-1);

$dbh = new PDO('mysql:host=127.0.0.1;dbname=1705php', 'root', 'root');
echo $dbh->exec($sql);
?>